- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8
Add datetime formatting capability to variable set task #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jessehouwing <[email protected]>
Co-authored-by: jessehouwing <[email protected]>
Co-authored-by: jessehouwing <[email protected]>
Co-authored-by: jessehouwing <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds datetime formatting capability to the variable set task, enabling users to set variables to the current date/time with custom formatting.
- Added a new "datetime" option to the variable source picker with configurable format patterns
- Implemented date/time formatting function supporting common patterns (yyyy, MM, dd, HH, mm, ss, tt)
- Updated TypeScript build info files across multiple task versions
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
| File | Description | 
|---|---|
| vsts-variable-set/v3/task.json | Added "datetime" option to picker and new DateTimeFormat input field | 
| vsts-variable-set/v3/vsts-variable-set.ts | Implemented formatDateTime function and datetime case in getValue | 
| vsts-variable-set/v*/tsconfig.tsbuildinfo | Updated TypeScript build info to version 5.8.3 | 
| vsts-variable-transform/v*/tsconfig.tsbuildinfo | Updated TypeScript build info to version 5.8.3 | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } | ||
| case "datetime": | ||
| { | ||
| const format = tl.getInput("DateTimeFormat", true) || "yyyy-MM-dd HH:mm:ss"; | 
    
      
    
      Copilot
AI
    
    
    
      Sep 2, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback default format conflicts with the task.json defaultValue. If DateTimeFormat is required (true), the fallback will never be used, making this redundant. Either make the input optional or remove the fallback.
| const format = tl.getInput("DateTimeFormat", true) || "yyyy-MM-dd HH:mm:ss"; | |
| const format = tl.getInput("DateTimeFormat", true); | 
| formatted = formatted.replace(/HH/g, hour); | ||
|  | ||
| // Hour 12-hour patterns | ||
| const hour12 = (now.getHours() % 12 || 12).toString().padStart(2, '0'); | 
    
      
    
      Copilot
AI
    
    
    
      Sep 2, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hh pattern for 12-hour format is not documented in the task.json helpMarkdown. The help text only mentions HH (24-hour) but not hh (12-hour).
This pull request adds support for setting variables to the current date/time in the
vsts-variable-settask, allowing users to specify a custom format for the date/time value. It also updates TypeScript build info files for bothvsts-variable-setandvsts-variable-transformtasks to reflect the latest build.New date/time variable feature
"datetime": "current date/time"to theFrompick list invsts-variable-set/v3/task.json, enabling selection of the current date/time as a variable source.DateTimeFormatinvsts-variable-set/v3/task.jsonfor specifying the format of the date/time value, with help text describing supported patterns.formatDateTimefunction invsts-variable-set/v3/vsts-variable-set.tsto replace format patterns (e.g.,yyyy,MM,dd,HH,mm,ss,tt) with the corresponding values from the current date/time.getValuefunction invsts-variable-set/v3/vsts-variable-set.tsto handle the new"datetime"option and use theDateTimeFormatinput for formatting.Build info updates
tsconfig.tsbuildinfo) for all versions ofvsts-variable-setandvsts-variable-transformto reflect the current build version. [1] [2]